<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>常用的js写法</title>
</head>
<body>
<script>
    //创建对象
    var obj=new Object();
    obj.field='赋予属性值';
    //获取属性值
    var field=obj.field;

    //常用的数组集合
    var arr=new Array();
    arr.forEach(function(value,index){
        console.log(index+'--'+value);
    })
    arr.push("添加元素");

    var fruits = ["Banana", "Orange", "Apple", "Mango"];
    if(fruits.indexOf("Apple") > -1){
        console.log('数组中包含Apple')
    }else{
        console.log('数组中不包含Apple')
    }

    //拼接成"BananaOrangeAppleMango
    var value_1 = fruits.join("");
    //拼接成"Banana,Orange,Apple,Mango"
    var value_2 = fruits.join(",");

    //js的排序
    var grades = [
        {
            "name": "张三",
            "grade": 95
        },
        {
            "name": "李四",
            "grade": 62
        },
        {
            "name": "王五",
            "grade": 86
        }
    ];
    grades.sort(function(a, b) { return a.grade - b.grade })





</script>
</body>
</html>